// InventoryManager.cs
using UnityEngine;

public class InventoryManager : Singleton<InventoryManager>
{
    
    [Header("道具初始次数")]
    public int initialHookUses = 3;
    public int initialHarpoonUses = 5;
    
    // 当前剩余次数（私有字段+属性保护）
    private int _hookUses;
    private int _harpoonUses;
    public int HookUses => _hookUses;
    public int HarpoonUses => _harpoonUses;


    // 重置道具次数（用于关卡开始）
    public void ResetInventory()
    {
        _hookUses = initialHookUses;
        _harpoonUses = initialHarpoonUses;
        OnInventoryChanged?.Invoke(); // 触发UI更新
    }

    // 使用道具方法
    public bool UseHook()
    {
        if (_hookUses > 0)
        {
            _hookUses--;
            OnInventoryChanged?.Invoke();
            return true;
        }
        return false;
    }

    public bool UseNet()
    {
        if (_harpoonUses > 0)
        {
            _harpoonUses--;
            OnInventoryChanged?.Invoke();
            return true;
        }
        return false;
    }
    

    // 事件：当道具数量变化时通知UI
    public event System.Action OnInventoryChanged;
}